home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
5579
/
5579.xpi
/
components
/
piclensjshelper.js
< prev
Wrap
Text File
|
2010-01-06
|
4KB
|
112 lines
// Copyright 2008-2009, Cooliris Inc.
function PicLensJSHelper() {}
PicLensJSHelper.prototype = {
xpiPath getter: function() {
return __LOCATION__.parent.parent.path;
},
frontDocument getter: function() {
var tabBrowser = this._frontTabBrowser();
if (tabBrowser) {
var tab = tabBrowser.selectedBrowser;
return tab.contentDocument;
} else {
return null;
}
},
openUrl: function(url, newTab, selectTab) {
var tabBrowser = this._frontTabBrowser();
if (!tabBrowser) {
return;
}
if (newTab) {
var tab = tabBrowser.addTab(url);
if (selectTab) tabBrowser.selectedTab = tab;
} else {
tabBrowser.selectedBrowser.contentDocument.location = url;
}
},
openHiddenBrowser: function(url) {
var tabBrowser = this._frontTabBrowser();
if (!tabBrowser) {
return null;
}
var browser = tabBrowser.ownerDocument.createElementNS(
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "browser");
browser.setAttribute("type", "content");
browser.setAttribute("src", url);
// For debugging:
// browser.setAttribute("style", "width: 300px;");
browser.setAttribute("style", "display: none;");
tabBrowser.appendChild(browser);
return browser;
},
closeHiddenBrowser: function(browser) {
var tabBrowser = this._frontTabBrowser();
if (!tabBrowser) {
return;
}
tabBrowser.removeChild(browser);
},
setToolbarLaunchIcon: function(win, doc, name) {
var button = win.document.getElementById('piclens-toolbarbutton2');
var selectedDoc = win.getBrowser().selectedBrowser.contentDocument;
if (button && doc === selectedDoc) {
button.className = "cooliris-toolbarbutton-" + name;
}
},
isBrowserForDocument: function(browser, doc) {
return (browser.contentDocument === doc);
},
getUserAgentString: function(win) {
return win.navigator.userAgent;
},
_frontTabBrowser: function() {
var mediator = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var win = mediator.getMostRecentWindow("navigator:browser");
return win ? win.getBrowser() : null;
},
QueryInterface: function(iid) {
if (!iid.equals(Components.interfaces.IPicLensJSHelper) &&
!iid.equals(Components.interfaces.nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
};
var PicLensJSHelperModule = {
registerSelf: function(compMgr, fileSpec, location, type) {
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation(this.classId, this.className, this.contractId,
fileSpec, location, type);
},
getClassObject: function(compMgr, cid, iid) {
if (!cid.equals(this.classId))
throw Components.results.NS_ERROR_NO_INTERFACE;
if (!iid.equals(Components.interfaces.nsIFactory))
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
return this.factory;
},
canUnload: function(compMgr) {
return true;
},
classId: Components.ID("a0ff7c31-77e1-4d6a-a6c6-c312ec2fbed4"),
className: "PicLensJSHelper",
contractId: "@cooliris.com/piclens/jshelper;1",
factory: {
createInstance: function(outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return (new PicLensJSHelper()).QueryInterface(iid);
}
}
};
function NSGetModule(compMgr, fileSpec) {
return PicLensJSHelperModule;
}